//
//  ClientNetworkCenter.h
//  Karaoke
//
//  Created by Ka Leung Ke on 11-10-17.
//  Copyright 2011年 __MyCompanyName__. All rights reserved.
//
#ifdef DEBUG
  #define CLog(format, ...) NSLog(format, ## __VA_ARGS__)
#else
  #define CLog(format, ...)
#endif

#import <Foundation/Foundation.h>
#import "AsyncSocket.h"
#import "SongObject.h"
#import "DataCenter.h"

static const int    FMP_MAX_AUD_VOLUME = 60;
static const int    pcNone = 0;             // 无
static const int    pcReg = 1;              // 注册
static const int    pcGetSysPara = 2;       // 获取系统参数
static const int    pcGetSongVer = 3;       // 获取歌库版本
static const int    pcUpdatePlayQueue = 5;  // 更新歌曲列表
static const int    pcGetPlayQueue = 4;     // 获取己选歌曲列表
static const int    pcAddSong = 6;          // 增加歌曲
static const int    pcDeleteSong = 7;       //删除歌曲
static const int    pcPrioritySong = 8;     // 优先歌曲

static const int    pcPauseState = 10;      // 暂停状态
static const int    pcStop = 9;             // 停止
static const int    pcPauseOrPay = 11;      // 暂停或播放
static const int    pcReplay = 12;          // 重唱
// static const int pcPlayEnd = 13;        // 播放结束

static const int    pcVolume = 15;          // 音量
static const int    pcSetMute = 16;         // 设置静音
static const int    pcMuteState = 17;       // 显示静音状态
static const int    pcGetCurrent = 18;      // 获取当前正播放的歌曲
static const int    pcBC = 19;              // 伴唱
static const int    pcYC = 20;              // 原唱
static const int    pcClientReg = 21;       // 包厢注册
static const int    pcTiaoGuang = 30;       // 调光
static const int    pcTiaoGuangState = 31;  // 通知调光状态
static const int    pcTiaoYin = 32;         // 调音
static const int    pcTiaoYinState = 33;    // 调音状态
static const int    pcDianShiPinDao = 40;   // 电视频道
static const int    pcStopDianShi = 41;
static const int    rtSysDate = 64;
static const int    rtGetRoomReport = 75;   // 请求DJ工作报告
static const int    rtSaveRoomReport = 76;  // 保存DJ工作报告
static const int    rtDianShiPinDao = 77;   // 获取电视频道
static const int    rtShowGongGuan = 78;    // 请求公关列表
static const int    rtHallBound = 90;
static const int    rtYeWuJingLiBound = 91;
static const int    rtDJManagerBound = 92;
static const int    rtZiKeBound = 93;
static const int    rtDuChaBound = 94;
static const int    rtManagerBound = 95;
static const int    rtLeadRoom = 96;
static const int    rtCancelLeadRoom = 97;
static const int    rtRoomRegistClerk = 99;
static const int    rtBound = 100;              // 绑定
static const int    rtClientRegist = 101;       // 客户端向服务端登记
static const int    rtClerkName = 102;          // 根据IC卡号或密码请求服务器返回员工姓名
static const int    rtFoodType = 103;           // 请求服务端返回酒水类别数据
static const int    rtFoodList = 104;           // 请求服务端返回酒水数据
static const int    rtSelectFood = 105;         // 点酒水命令
static const int    rtAddInfoOfFood = 106;      //服务端返回酒水附加项目选项
static const int    rtPackChild = 107;          //服务端返回套餐子项数据
static const int    rtAutoFreeFood = 108;       //服务端返回自动赠送的酒水数据
static const int    rtBillInfo = 109;           // 请求服务端返回账单信息
static const int    rtOpenRoom = 110;           // 向服务端发出开房台的命令
static const int    rtPleaseSettle = 111;       // 向服务端发出申请结账的命令
static const int    rtClearRoom = 112;          // 向服务端发出置可用房的命令
static const int    rtConfirmDiscount = 113;    // 向服务端发出执行经理折扣的命令
static const int    rtConfirmInputFood = 114;   // 向服务端发出确认落单的命令
static const int    rtConfirmFreeFood = 115;    // 向服务端发出确认赠送的命令
static const int    rtServiceList = 116;        // 请求服务端返回可供选择服务的列表
static const int    ftSelectService = 117;      // 请求服务
static const int    rtRoomStates = 118;         // 房台状态列表
static const int    rtRoomStateAndInfo = 119;   // 返回选中房台的状态，如空房、已预订、消费中等

static const NSString *boudType = @"0";         // 绑定类型 0:不固定员工1:固定员工绑定
@interface ClientNetworkCenter : NSObject
{
    AsyncSocket         *mainSocket;
    BOOL                isConnect;
    NSMutableData       *receiveData;
    int                 dataOffset;
    NSString            *lastConnectIp;
    int                 lastConnectPort;
    NSTimer             *retryTimer;
    NSStringEncoding    encGBK;
}

@property BOOL isConnect, isStopRetry;
+ (ClientNetworkCenter *)sharedInstance;

- (void)sentMsgAskForAddSongWithCode:(NSString *)tempSongCode;
- (void)sentMsgAskForPushSongWithCode:(NSString *)tempSongCode;
- (void)sentMsgAskForCutSong;
- (void)connectToServerWithIp:(NSString *)tempIp:(int)tempPort;
- (void)sentMsgAskForChangeToOriginalMusic;
- (void)sentMsgAskForChangeToSideMusic;
- (void)sentMsgAskForMute;

- (void)sentMsgAskForChangeVol:(int)tempVol;
- (void)sentMsgAskForReplay;
- (void)sentMsgAskForPauseOrPlay;

- (void)sentMsg:(int)cmd:(NSString *)para, ...;
- (void)disconnectToServer;
- (void)sentMsgAskForBillList;
- (BOOL)checkIfVaildMsg:(NSData *)tempData;
- (void)sentMsgAskForDelSongWithCode:(NSString *)tempSongCode;
- (void)stopRetry;
- (void)retryConnectLastConnection;
- (void)sendMsg:(int)cmd:(NSArray *)para;
- (void)sendMsg:(int)cmd;
- (BOOL)getConnected;

@end